<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图片分层</title>
    <style>
        *{margin: 0;padding: 0;}
        .out{width: 1100px;margin: 0 auto; border: 1px solid red;}
        .out::after{content: "";display: block;clear: both;}
        .box{width: 200px;height: 350px;float: left;margin-right: 100px;margin-bottom: 100px;}
        .box:nth-child(4n){margin-right: 0px;}

        @media(max-width:768px) {
            .out{width: 100%;}
            .box{width: 200px;float: none;margin: 0 auto;margin-bottom: 100px;}
            .box:nth-child(4n){margin-left: auto;margin-right: auto;}
        }
        @media(min-width:768px) {
            .out{width: 680px;}
            .box{width: 200px;margin-right: 280px;}
            .box:nth-child(2n){margin-right: 0px;}
        }
        @media(min-width:992px) {
            .out{width: 800px;}
            .box{width: 200px;margin-right: 100px;}
            .box:nth-child(2n){margin-right: 100px;}
            .box:nth-child(3n){margin-right: 0px;}
        }
        @media(min-width:1200px) {
            .out{width: 1100px;}
            .box{width: 200px;margin-right: 100px;}
            .box:nth-child(3n){margin-right: 100px;}
            .box:nth-child(4n){margin-right: 0px;}
        }
    </style>

</head>
<body>
    <div class="out">
        <div class="box"><img src="img/1.jpg"></div>
        <div class="box"><img src="img/2.jpg"></div>
        <div class="box"><img src="img/3.jpg"></div>
        <div class="box"><img src="img/4.jpg"></div>
        <div class="box"><img src="img/5.jpg"></div>
        <div class="box"><img src="img/6.jpg"></div>
        <div class="box"><img src="img/7.jpg"></div>
        <div class="box"><img src="img/8.jpg"></div>
        <div class="box"><img src="img/9.jpg"></div>
        <div class="box"><img src="img/10.jpg"></div>
    </div>
</body>
</html>